package com.csjbot.weedle_auto.fragment.manual

import com.csjbot.weedle_auto.SerialServer.util.bean.SerialPortEvents
import com.csjbot.weedle_auto.SerialServer.util.bean.SerialPortOtherBean

/**
 * author : chenqi.
 * e_mail : 1650699704@163.com.
 * create_time : 8/21/17.
 */

class ManualPresenter(private val view: ManualContract.view) : ManualContract.presenter {

    init {
        view.setPresenter(this)
    }

    override fun start() {
        //fragment不能写成开始
    }

    override fun setSerialPortInforMation(serialPortInformMotion: SerialPortEvents) {
        when (serialPortInformMotion.event) {
            SerialPortEvents.Event.INFRARED -> {
            }
            SerialPortEvents.Event.OA -> {
            }
            SerialPortEvents.Event.TOUCH -> if (serialPortInformMotion.m is Int) {
                view.touch(serialPortInformMotion.m as String)
            }
            SerialPortEvents.Event.SNDOWN -> if (serialPortInformMotion.m is String) {
                view.snDown(serialPortInformMotion.m as String)
            }
            SerialPortEvents.Event.SNUP -> if (serialPortInformMotion.m is String) {
                view.snUp(serialPortInformMotion.m as String)
            }
            SerialPortEvents.Event.OTHER -> if (serialPortInformMotion.m is SerialPortOtherBean) {
//                val s = serialPortInformMotion.m as SerialPortOtherBean
//                val bt = DataUtil.isIBean(s.infrared)
//                val pbt = DataUtil.isPINR(s.platE_INFRARED)
                //                    view.other(s.getSCR(), inr.toString(), p.toString(), s.getOA());
            }
            SerialPortEvents.Event.WAKEUP -> {
            }
        }
        //传个对象
        //        view.showTestResults("成功", "成功", "成功", "成功", "成功", "成功", "成功");//view显示数据
    }
}
